{if isset($WEB_APP.fields)}{if !isset($WEB_APP.unshow_asterisk)}<div class="alert alert-info">{$text.txt_fields_marked_with_an_asterisk_are_required}</div>{/if}{/if}

<form class="form-horizontal" action = "{$WEB_APP.action_url}" method = POST name = "FORM" {if isset($WEB_APP.form_enctype) eq TRUE}enctype = "multipart/form-data"{/if}>
{if isset($WEB_APP.fields)}
	
	<fieldset class="well">
	{assign var="tmp" value="2"}
	{foreach from = $WEB_APP.fields item = field name = foreach_item}
		{if $tmp eq 2}
			{assign var="tmp" value="1"}
		{else}
			{assign var="tmp" value="2"}
		{/if}

        
		{if $field->type eq 'submit_form'}
			<input type = "submit" class = "btn" value = "{$submit_title}" name="{$field->name}">&nbsp;
			<input type = "button" class = "btn" value = "{$text.txt_help}" onclick = "window.open('{$WEB_APP.help_url}', 'mywindow')" name="help_button">
		    {assign var="show_header_footer" value="0"}
            {php} continue; {/php}
		{/if}
		
		
		{if $field->type eq "header"}
		</fieldset>
            {if !isset($show_header_footer)}{/if}
			{assign var="tmp" value="2"}
			<h3>{$field->title}:</h3>
		<fieldset class="well">
		{else}	
		<div class="control-group">
			<label class="control-label">{if $field->require}*{/if}{$field->title}:</label>
		
			<div class="controls">
			{if $field->type eq "textarea"}
				<textarea name = "{$field->name}" wrap = "virtual" id = "{$field->id}">{$field->value|escape}</textarea>
			{else}
				{if ($field->type eq "select") or ($field->type eq "multiple_select")}
					<select class="input-xlarge" name = "{$field->name}" id="{$field->name}" 
					{if isset($field->on_change)}onchange="{$field->on_change}"{/if} 
					{if $field->type eq "multiple_select"}multiple size="8"{/if}>
					{if isset($WEB_APP.show_empty_value) eq FALSE}
						<option value = "" 
						{if $field->value eq ""}SELECTED{/if}
						></option>
					{/if}
					{assign var = "value" value = $field->option_value_field}
					{assign var = "tmptext" value = $field->option_text_field}
					{foreach from = $field->array item = item}
						{if $field->type eq "select"}<option value = "{$item[$value]|escape}" {if $field->value eq $item[$tmptext]}SELECTED{/if}>{$item[$tmptext]|escape}</option>{/if}
						{if $field->type eq "multiple_select"}<option value = "{$item[$value]|escape}" {if in_array($item[$tmptext], $field->value) }SELECTED{/if}>{$item[$tmptext]|escape}</option>{/if}
					{/foreach}
					</select>
					{if isset($field->on_change) && $field->show_button}&nbsp;<input type="submit" class="btn" name="select_button" value="{$text.txt_select}">{/if}
					{if $field->show_description}&nbsp;<div id="{$field->name}_description_item"></div>{/if}					
				{else}
					<input type = "{$field->type}" name = "{$field->name}" 
					{if $field->type eq "checkbox"}
						{if $field->value eq 1}CHECKED{else}UNCHECKED{/if}
					{else}
						value = "{$field->value|escape}"
					{/if}
					id = "{$field->id}" {if $field->type eq "file"}size="59%"{else}size = "70%"{/if}>
				{/if}			
			{/if}
			</div>
		</div>	
	{/if}	
	{/foreach}
</fieldset>
{/if}

{if (!isset($show_buttons)) || (isset($show_buttons) && ($show_buttons neq 0))}
		<div align="right"><input type = "submit" class = "btn-primary" value = "{$submit_title}" name="submit_button">&nbsp;<input type = "button" class = "btn" value = "{$text.txt_help}" onclick = "window.open('{$WEB_APP.help_url}', 'mywindow')" name="help_button"></div>

</form>
{if isset($WEB_APP.scripts) && in_array('shortcuts.js', $WEB_APP.scripts)}
<script>
        {literal}
		shortcut.add("Enter",function() {
		document.FORM.submit_button.click();
		},{
		'type':'keydown',
		'propagate':true,
		'target':document
		});{/literal}
</script>
{/if}

{/if}

